$(function () {
    var carousel = layui.carousel;

    carousel.render({
        elem: '#slide-cont'
        ,width: '100%'
        ,arrow: 'always'
        ,height:'480px'
    });

    //短信计时器
    $(document).on("click","#getEmailCodeBtn",function () {
        var seconds = 60;
        var _this = $(this);
        var timer = setInterval(function () {
            seconds --;
            _this.text(seconds+'秒后获取').attr("disabled",true).addClass("layui-btn-disabled");
            if(seconds===0){
                _this.text('获取验证码').removeAttr("disabled").removeClass('layui-btn-disabled');
                seconds = 60;
                clearInterval(timer)
            }
        },1000);
        $.ajax({
            type:'post',
            url:_this.data('url'),
            data:{
                email:$("#usernameInput").val()
            },
            dataType:'json',
            success:function (res) {
                layer.msg(res.msg)
            },
            error:function (err) {
                layer.msg("网络错误请稍后再试");
            }
        });
    });

    //登录注册
    $(document).on("click",".registerBtn,.loginBtn,.findPwdBtn",function () {
        openHtml(false,$(this).data('url'),'440px','623px',function () {
            submit("regLogin",function (res) {
                if(res.code===1){
                    location.href="";
                }
            })
        });
    });

    //文章订阅服务
    $(document).on("click",".arcSubscribe",function(){
        var url = $(this).data("href"),html= $(".subscribe");
        var form = layui.form;
        layer.open({
            content:html.html(),
            ara:["300px","400px"],
            success:function () {
                form.render();
                form.on('checkbox(subscribe)', function(data){
                    $('.arcsubform').find('.layui-input').prop("checked",data.elem.checked);
                    form.render('checkbox');
                });
                form.on("submit(subscribe)",function(data){
                    createSubscribe(url,data.field);
                    return false
                })
            },
            btn:false,
        })
    })


});
